package com.qzsoft.zhjd.machine.modules.machinerepair.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.qzsoft.jeemis.common.validator.group.AddGroup;
import com.qzsoft.jeemis.common.validator.group.UpdateGroup;

import lombok.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * @author HuXiuMing
 * @date 2021/10/21 15:49
 */

@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
@TableName("machine_repair")
public class MachineRepairEntity {

    /**
     * 主键
     */
    @NotBlank(groups = UpdateGroup.class, message = "标识不可为空")
    @TableId(type = IdType.ASSIGN_UUID)
    private String id;

    /**
     * 部门ID
     */
    @Length(groups = {AddGroup.class,UpdateGroup.class},max = 36,message = "隶属单位id长度不可超过{max}个字")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String deptId;

    /**
     * 部门PkID
     */
    @Length(groups = {AddGroup.class,UpdateGroup.class},max = 36,message = "部门PkID长度不可超过{max}个字")
    @TableField(updateStrategy = FieldStrategy.NEVER)
    private String deptPkid;

    /**
     * 设备主键
     */
    @NotBlank(groups = AddGroup.class, message = "机械设备不可为空")
    @Length(groups = {AddGroup.class,UpdateGroup.class},max = 36,message = "设备主键长度不可超过{max}个字")
    private String machineId;

    /**
     * 维修时间
     */
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "维修时间不可为空")
    @JsonFormat(pattern = "yyyy-MM-dd",  timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date day;

    /**
     * 维修费用
     */
    @NotNull(groups = {AddGroup.class, UpdateGroup.class}, message = "维修费用不可为空")
    private BigDecimal amount;

    /**
     * 维修描述
     */
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "维修描述不可为空")
    @Length(groups = {AddGroup.class, UpdateGroup.class}, max = 200, message = "维修描述不可超过{max}个字")
    private String info;

    /**
     * 创建者
     */
    @TableField(fill = FieldFill.INSERT, updateStrategy = FieldStrategy.NEVER)
    private Long creator;

    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE, updateStrategy = FieldStrategy.NEVER)
    private Date createDate;

    /**
     * 更新者
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Long updater;

    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateDate;
    
    @TableField(exist = false)
    @Valid
    private List<MachineRepairImgEntity> imageList;
}
